<?php
namespace app\screenshot\admin;
use app\admin\controller\Admin;
use app\screenshot\model\ScreenshotTemtype as TypeModel;
use think\Db;


class Order extends Admin
{
    public function index()
    {
        $_page = input('param.page/d', 0);
        $_keywords = input('param.keywords/s');
        $map = [];
     
       $data_list = Db::name('screenshot_order o')->join('admin_member m','o.uid = m.id')->where('o.status','1')->limit(10)->page($_page)->order('create_time desc')->select();
       $this->assign('data_list', $data_list);
       $count =  Db::name('screenshot_order o')->join('admin_member m','o.uid = m.id')->where('o.status','1')->count();
       $this->assign('count', $count);
       $this->assign('nowPage', $_page);
        return $this->fetch();
    }

    public function add()
    {
        if ($this->request->isPost()) {
            $mod = new TypeModel();
            if (!$mod->storage()) {
                return $this->error($mod->getError());
            }
            return $this->success('保存成功');
        }
       //$category = CategoryModel::getSelect(CategoryModel::getChilds());
       // $this->assign('category', $category);
        return $this->fetch('form');
    }

    public function edit()
    {
        $id = get_num();
        if ($this->request->isPost()) {
            $mod = new TypeModel();
            if (!$mod->storage()) {
                return $this->error($mod->getError());
            }
            return $this->success('保存成功');
        }
        $row = TypeModel::where('id', $id)->find();
        if (!$row) {
            return $this->error('数据不存在');
        }
        $this->assign('data_info', $row);
        return $this->fetch('form');
    }
    
}